﻿using UnityEngine;
using System.Collections;

public class SquareLancer : Square {
	public CommonProperty prop;
	public AudioSource seMove;
	public AudioSource seAttack;
 
	protected override void InitInheritSquare()
	{
		leader.evtLeadEvent += OnLeaderAction;
	}

	public void OnHit (Square sqr)
	{
		//base.OnHit ();

	}

	public void OnHurt (Square sqr)
	{
		//base.OnHurt ();

		if (null == sqr)
			return;

		CommonProperty enemyProperty = sqr.GetComponent<CommonProperty> ();

		if (null == enemyProperty)
			return;

		if (prop.healthPoint < 0)
		{
			eState = ESquareState.emDead;
		}
	}

	public void OnLeaderAction(object sender, LeaderMsg evt)
	{
		switch (evt.eAction)
		{
		case ELeaderAction.emAttack:
			LancerAttack();
			break;
		case ELeaderAction.emMove:
			LancerMove();
			break;
		case ELeaderAction.emStopMove:
			LancerStop();
			break;
		default:
			break;
		}
	}

	void LancerMove()
	{
		Debug.Log("play move sound!");
		seMove.Play ();
	}

	void LancerAttack()
	{

	}

	void LancerStop()
	{
		Debug.Log("stop move sound!");
		seMove.Stop ();
	}
}
